package com.test.wog.controller;

import com.test.wog.service.RoadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *关键通道的Controller层
 *
 * @author linxun@buaa.edu.cn
 * @since 2020-01-28
 */
@Api(value = "关键通道Controller", tags = {"关键通道操作接口"})
@RestController
public class RoadController {
    @Autowired
    RoadService rs;
    @ApiOperation(value = "关键通道查询", notes = "支持按名称或类型查询关键通道，名称和类型均为空时返回全部关键通道")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "通道名称", required = false, paramType = "query", defaultValue = "京张高铁"),
            @ApiImplicitParam(name = "type", value = "通道类型", required = false, paramType = "query", defaultValue = "铁路")
    })
    @RequestMapping(value = "/getRoad", method = RequestMethod.GET)
    @ResponseBody
    public String getNode(//根据特定输入筛选关键通道
        @RequestParam(value = "name",required = false) String name,
        @RequestParam(value = "type",required = false) String type
    ){
        if(name == null){
            if(type == null){
                return rs.getAllRoad();
            }
            return rs.getRoadByType(type);
        }
        return rs.getRoadByName(name);
    }
}
